package team.kirohuji.domain.user;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * 系统脚本
 * 
 * @author kirohuji
 *
 */
@Entity
@Table(name = "role")
public class Role implements Serializable {
	private static final long serialVersionUID = 7783681699251200222L;

	/**
	 * 主键
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "role_id")
	private Integer roleId;

	/**
	 * 是否可用：0停用，1启用
	 */
	private Integer avaliable;

	/**
	 * 角色名
	 */
	@Column(name="role_name")
	private String roleName;

	/**
	 * 描述
	 */
	private String description;

	/**
	 * 创建时间
	 */
	@Column(name="create_date")
	private Date createDate;
	
	@Column(name = "user_id")
	private Integer userId;
	
	/**
	 * @see User 用户列表
	 */
    @JsonIgnore
	@ManyToMany(mappedBy = "roles")
	private List<User> users;

	/**
	 * @see Priority 权限列表
	 */
    @JsonIgnore
	@ManyToMany(mappedBy = "roles")
	private List<Priority> priorities;	
	
	public Integer getUserId() {
		return userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}


	public List<Priority> getPriorities() {
		return priorities;
	}

	public void setPriorities(List<Priority> priorities) {
		this.priorities = priorities;
	}

	public Integer getRoleId() {
		return roleId;
	}

	public void setRoleId(Integer roleId) {
		this.roleId = roleId;
	}

	public Integer getAvaliable() {
		return avaliable;
	}

	public void setAvaliable(Integer avaliable) {
		this.avaliable = avaliable;
	}

	public String getRoleName() {
		return roleName;
	}

	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	@Override
	public String toString() {
		return "Role [roleId=" + roleId + ", avaliable=" + avaliable + ", roleName=" + roleName + ", description="
				+ description + ", createDate=" + createDate + "]";
	}

}